﻿@model PerformanceAssessment.Models.Goal

@{
    ViewBag.Title = "Edit";
}

@section Head
{
    <style type="text/css">
        .field_label
        {
            width:150px;
        }
        .description
        {
            width:650px;
        }
        textarea
        {
            font:inherit;
            width:690px;
        }
    </style>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
}

@using PerformanceAssessment.Models;

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Goal</legend>

        @Html.Hidden("assessmentId", (int)ViewBag.assessment.ID)

        @Html.HiddenFor(model => model.ID)
        @Html.HiddenFor(model => model.IdAssessment)

        <p>Goals and objectives must follow the "SMART" characteristics. The following fields describe the objective:</p>
        <table>
            <tr>
                <td class="field_label">Describe your Goal</td>
                <td class="description">
                    @if (ViewBag.assessment.EditionAllowed(ViewBag.userType, UserType.Employee) && !ViewBag.readOnly)
                    {
                        @Html.TextAreaFor(model => model.SpecificDescription, new { style = "width:690px;" })
                        @Html.ValidationMessageFor(model => model.SpecificDescription)
                    }
                    else
                    {
                        @Html.TextAreaFor(model => model.SpecificDescription, new { style = "width:690px;", disabled = "disabled" })
                    }
                </td>
            </tr>
            <tr>
                <td class="field_label">How can your goal be evaluate/measure if it was completed?</td>
                <td class="description">
                    @if (ViewBag.assessment.EditionAllowed(ViewBag.userType, UserType.Employee) && !ViewBag.readOnly)
                    {
                        @Html.TextAreaFor(model => model.MeasurableDescription, new { style = "width:690px;" })
                        @Html.ValidationMessageFor(model => model.MeasurableDescription)
                    }
                    else
                    {
                        @Html.TextAreaFor(model => model.MeasurableDescription, new { style = "width:690px;", disabled = "disabled" })
                    }
                </td>
            </tr>
            <tr>
                <td class="field_label">What actions / activities / tasks are you going to accomplish to complete your Goal?</td>
                <td class="description">
                    @if (ViewBag.assessment.EditionAllowed(ViewBag.userType, UserType.Employee) && !ViewBag.readOnly)
                    {
                        @Html.TextAreaFor(model => model.AttainableDescription, new { style = "width:690px;" })
                        @Html.ValidationMessageFor(model => model.AttainableDescription)
                    }
                    else
                    {
                        @Html.TextAreaFor(model => model.AttainableDescription, new { style = "width:690px;", disabled = "disabled" })
                    }
                </td>
            </tr>
            <tr>
                <td class="field_label">Why is your goal important for your position/current job or to the company?</td>
                <td class="description">
                    @if (ViewBag.assessment.EditionAllowed(ViewBag.userType, UserType.Employee) && !ViewBag.readOnly)
                    {
                        @Html.TextAreaFor(model => model.RelevantDescription, new { style = "width:690px;" })
                        @Html.ValidationMessageFor(model => model.RelevantDescription)
                    }
                    else
                    {
                        @Html.TextAreaFor(model => model.RelevantDescription, new { style = "width:690px;", disabled = "disabled" })
                    }
                </td>
            </tr>
            <tr>
                <td class="field_label">When are you going to complete your goal?</td>
                <td class="description">
                    @if (ViewBag.assessment.EditionAllowed(ViewBag.userType, UserType.Employee) && !ViewBag.readOnly)
                    {
                        @Html.TextAreaFor(model => model.TimelyDescription, new { style = "width:690px;" })
                        @Html.ValidationMessageFor(model => model.TimelyDescription)
                    }
                    else
                    {
                        @Html.TextAreaFor(model => model.TimelyDescription, new { style = "width:690px;", disabled = "disabled" })
                    }
                </td>
            </tr>
        </table>
        <div class="editor-label">
            @Html.LabelFor(model => model.Achieved)
        </div>
        <div class="editor-field">
            @if (ViewBag.assessment.EditionAllowed(ViewBag.userType, UserType.Manager) && !ViewBag.readOnly)
            {
                @Html.CheckBoxFor(model => model.Achieved)
                @Html.ValidationMessageFor(model => model.Achieved)
            }
            else
            {
                @Html.CheckBoxFor(model => model.Achieved, new { disabled = "disabled" })
            }
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Comments)
        </div>
        <div class="editor-field">
            @if (ViewBag.assessment.EditionAllowed(ViewBag.userType, UserType.Manager) && !ViewBag.readOnly)
            {
                @Html.TextAreaFor(model => model.Comments, new { style = "width:800px; font:inherit;" })
                @Html.ValidationMessageFor(model => model.Comments)
            }
            else
            {
                @Html.TextAreaFor(model => model.Comments, new { style = "width:800px; font:inherit;", disabled = "disabled" })
            }
        </div>

        <p>
        @if (ViewBag.assessment.EditionAllowed(ViewBag.userType, UserType.Manager, UserType.Employee) && !ViewBag.readOnly)
        {
            <input type="submit" value="Save" />
        }
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index", new { assessmentId = ViewBag.assessment.ID })
</div>
